#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFileDialog>
#include "resourcemanager.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent),
      ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    setMinimumSize(1024, 768);

    desktop = new Desktop(this);
    this->setCentralWidget(desktop);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::keyPressEvent(QKeyEvent *event)
{
    desktop->handleKeyPressEvent(event);
}

void MainWindow::keyReleaseEvent(QKeyEvent *event)
{
    desktop->handleKeyReleaseEvent(event);
}

void MainWindow::on_actionOpen_triggered()
{
    QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), "", "3d model files(*.stl *.obj)");
    if (!filePath.isEmpty())
    {
        desktop->loadModel(filePath);
    }
}
